//
//  falvTableViewCell.m
//  PASystem
//
//  Created by michael on 16/8/17.
//  Copyright © 2016年 czd. All rights reserved.
//
#import "WTOTableViewController.h"

#import "guoneiwaiViewController.h"
#import "huiyiguanliTableViewController.h"
#import "falvTableViewCell.h"
#import "maoyiTableViewController.h"
#import "InternationalMediationController.h"
#import "TrademarkController.h"
#import "ArbitrationController.h"
#import "GeneralOriginController.h"
#import "BeijingConsularController.h"
#import "ShangHaiConsularController.h"
#import "ATATableViewController.h"
#import "BussinessCertificateController.h"
@implementation falvTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
self.contentView.backgroundColor = myColor;

         view = [[UIView alloc]init ];
         
         view.backgroundColor = [UIColor whiteColor];
    
_button = [UIButton buttonWithType:UIButtonTypeCustom];

   _label = [[UILabel alloc]init];
    
    [self.contentView addSubview:view];
//        [view addSubview:_button];
//            [view addSubview:_label];

    
}

return self;

}
- (void)oneAction :(UIButton *)UIButton{

if ([_array[UIButton.tag] isEqualToString:@"国际调解管理"]) {
        InternationalMediationController *inVC = [[InternationalMediationController alloc] init];
        inVC.service = @"LegalAffairsService";
        inVC.string = _array[UIButton.tag] ;
        [self.ViewController.navigationController pushViewController:inVC animated:YES];
        
    }else if ([_array[UIButton.tag] isEqualToString:@"商标专利管理"]){
        TrademarkController *tra = [[TrademarkController alloc] init];
    tra.service = @"LegalAffairsService";
            tra.string = _array[UIButton.tag] ;

        [self.ViewController.navigationController pushViewController:tra animated:YES];
    
    }else if ([_array[UIButton.tag] isEqualToString:@"国际贸易仲裁管理"]){
    
        ArbitrationController *arVC = [[ArbitrationController alloc] init];
                    arVC.string = _array[UIButton.tag] ;

        arVC.service = @"LegalAffairsService";
        [self.ViewController.navigationController pushViewController:arVC animated:YES];
    
    }else if ([_array[UIButton.tag] isEqualToString:@"一般原产地证明"]){
        
        GeneralOriginController *orVC = [[GeneralOriginController alloc] init];
        
        orVC.type = GeneralOrigin;
        orVC.action = @"ybycdList";
        orVC.service = @"LegalAffairsService";
        
        [self.ViewController.navigationController pushViewController:orVC animated:YES];
        
    }else if ([_array[UIButton.tag] isEqualToString:@"优惠原产地证明"]){
        
        GeneralOriginController *orVC = [[GeneralOriginController alloc] init];
               orVC.action = @"yhycdList";
        orVC.service = @"LegalAffairsService";
        orVC.type = PreferentialOrigin;
        
        [self.ViewController.navigationController pushViewController:orVC animated:YES];
        
    }else if ([_array[UIButton.tag] isEqualToString:@"北京领事认证"]){
        
        BeijingConsularController *beiJVC = [[BeijingConsularController alloc] init];
        
        [self.ViewController.navigationController pushViewController:beiJVC animated:YES];
        
    }else if ([_array[UIButton.tag] isEqualToString:@"上海领事认证"]){
        
         ShangHaiConsularController*shVC = [[ShangHaiConsularController alloc] init];
        
        [self.ViewController.navigationController pushViewController:shVC animated:YES];
        
    }else if ([_array[UIButton.tag] isEqualToString:@"ATA"]){
        
        ATATableViewController*ATAVC = [[ATATableViewController alloc] init];
        
        [self.ViewController.navigationController pushViewController:ATAVC animated:YES];
        
    }else if ([_array[UIButton.tag] isEqualToString:@"国际商事证明书"]){
        
        BussinessCertificateController *BCVC = [[BussinessCertificateController alloc] init];
        
        [self.ViewController.navigationController pushViewController:BCVC animated:YES];
        
    }
    






if ([_array[UIButton.tag] isEqualToString:@"国内活动"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国内活动";
        guowai.type = @"1";
        guowai.action = @"wsjlList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"国外活动"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国外活动";
        guowai.type = @"2";
        guowai.action = @"wsjlList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"国内接待"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国内活动";
        guowai.type = @"1";
        guowai.action = @"wsjdList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"国外接待"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国外接待";
        guowai.type = @"2";
        guowai.action = @"wsjdList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}

if ([_array[UIButton.tag] isEqualToString:@"培训"]) {
    huiyiguanliTableViewController *guowai = [[huiyiguanliTableViewController alloc]init];
        guowai.string = @"培训";
        guowai.type = @"1";
        guowai.action = @"xchdList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"考查走访"]) {
    huiyiguanliTableViewController *guowai = [[huiyiguanliTableViewController alloc]init];
        guowai.string = @"考查走访";
        guowai.type = @"2";
        guowai.action = @"xchdList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"联系机构"]) {
    huiyiguanliTableViewController *guowai = [[huiyiguanliTableViewController alloc]init];
        guowai.string = @"联系机构";
        guowai.type = @"3";
        guowai.action = @"xchdList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}


if ([_array[UIButton.tag] isEqualToString:@"贸易摩擦管理"]) {
    maoyiTableViewController *guowai = [[maoyiTableViewController alloc]init];
        guowai.string = @"贸易摩擦管理";
//        guowai.type = @"3";
        guowai.action = @"mymcList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"WTO贸易政策审议"]) {
    WTOTableViewController *guowai = [[WTOTableViewController alloc]init];
        guowai.string = @"WTO贸易政策审议";
//        guowai.type = @"3";
        guowai.action = @"wtoList";
        guowai.service = @"LegalAffairsService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}




}
- (void)layoutSubviews{
[super layoutSubviews];
view.frame =  CGRectMake(5, 5, KScreenWidth-10, self.contentView.height-10);
float itemWidth = (view.width-160) /4;
for (int j = 0;j<_array.count;j++)
         {
         _button = [UIButton buttonWithType:UIButtonTypeCustom];
       

                    _button.tag = j;
   
     [_button addTarget:self action:@selector(oneAction:) forControlEvents:UIControlEventTouchUpInside];
if (j>=4) {
    _button.frame  = CGRectMake(20+(itemWidth+40)*(j-4), 5+(itemWidth+20), itemWidth, itemWidth);

}
if (j<4){
_button.frame  = CGRectMake(20+(itemWidth+40)*j, 5, itemWidth, itemWidth);
}
 [_button setBackgroundImage:[UIImage imageNamed:_array[j]] forState:UIControlStateNormal];
  _label = [[UILabel alloc]init];

_label.frame = CGRectMake(_button.left-10, _button.bottom+5, _button.width+20, 10);
_label.font = [UIFont systemFontOfSize:10];//采用系统默认文字设置大小
_label.textAlignment = NSTextAlignmentCenter;
    _label.text = _array[j];
    [view addSubview:_label];
 [view addSubview:_button];
         
         
         
         }
         



}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
